package com.example.mymvvmdemo.net.presenter;


import com.example.mymvvmdemo.MyApplication;
import com.example.mymvvmdemo.net.model.DeleteModel;
import com.example.mymvvmdemo.net.model.IModel;
import com.example.mymvvmdemo.net.view.IView;
import com.example.mymvvmdemo.utils.LogUtils;

import java.util.HashMap;

/**
 * 普通Delete请求统一presenter
 */
public class DeletePresenter implements IModel.DeleteModel {

    private DeleteModel DeleteModel = new DeleteModel(this);

    private IView.DeleteView DeleteView;

    public DeletePresenter(IView.DeleteView DeleteView) {
        this.DeleteView = DeleteView;
    }

    public void startLoadDelete(String url, HashMap<String, String> hashMap, String type) {
        DeleteModel.startLoadDelete(url, MyApplication.getAuthToken(), hashMap, type);
    }


    //回调给view
    @Override
    public void loadDeleteSuccess(String result, String type, int code) {
        LogUtils.d("load Delete success type:" + type + ",result:" + result);
        LogUtils.printJson(result, type);
        DeleteView.loadDeleteSuccess(result, type, code);
    }

    @Override
    public void loadDeleteFail(String message, String type) {
        LogUtils.d("load Delete fail type:" + type + ",message:" + message);
        DeleteView.loadDeleteFail(message, type);
    }

    @Override
    public void loadDeleteAccountError(int code) {
        LogUtils.d("load Delete account error code :" + code);
        DeleteView.loadDeleteAccountError(code);
    }

    @Override
    public void loadDeleteNetWorkError(String message) {
        LogUtils.d("load Delete network error :" + message);
        DeleteView.loadDeleteNetWorkError(message);
    }

}
